package mmc.server.shell.ops.baseops;

import mmc.server.shell.*;
import mmc.server.shell.ops.*;

public class SubAssignment extends Operation {

    public SubAssignment(String text) throws ShellException {
        super(text, "-=", true, true);
        
        if(!(lValue instanceof Assignable)){
        	throw new OperationNotAcceptedException(true, " lvalue is not a variable! ("+lValue.getClass().getName()+")");
        }
    }

    @Override
    public double execute() {
    	double value = lValue.execute()-rValue.execute();
    	((Assignable)lValue).set(value);
    	
    	return value;
    }
    
    public static PriorityType getPriorityType() {
        return PriorityType.ASSIGNMENT;
    }
    
    public static String getDescription(){
    	return formatHelpString("-=","subtraction & assignment");
    }
}
